home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 4 / Amiga Tools 4.iso / tools / mail-tools / thor / thor_2.22 / thor.lha / rexx / PGPAddToKeyRing.thor < prev    next >
Text File  |  1995-12-18  |  2KB  |  98 lines

  1. /* $VER: PGPAddToKeyRing.thor 3.1 (06.02.95)
  2.  *
  3.  * Arexx script to add a PGP key to the public keyring. The key is taken
  4.  * from the current message in Thor.
  5.  *
  6.  * Script by: Eivind Nordseth, Ultima Thule Software.
  7.  */
  8.  
  9. /* trace results */
  10.  
  11. options results
  12.  
  13. p = address() || ' ' || show('P',,)
  14. thorport = pos('THOR.',p)
  15.  
  16. if thorport > 0 then thorport = word(substr(p,thorport),1)
  17. else
  18. do
  19.     say 'No THOR port found!'
  20.     exit 10
  21. end
  22.  
  23. if ~show('p', 'BBSREAD') then do
  24.     address command
  25.         "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
  26.         "WaitForPort BBSREAD"
  27. end
  28.  
  29. filename = 't:pgptext'
  30.  
  31. address command 
  32. if exists(filename) then 'delete >nil:' filename
  33.  
  34. address(thorport)
  35. SAVEMESSAGE CURRENT FILE filename NOHEADER
  36. if(rc ~= 0) then 
  37. do 
  38.     REQUESTNOTIFY TEXT '"Not able to save current message."' BT '"_Ok"'
  39.     exit
  40. end
  41.  
  42. address command 'search >nil:' filename '"BEGIN PGP PUBLIC KEY" QUICK QUIET' 
  43. if(rc = 5) then
  44. do
  45.     REQUESTNOTIFY TEXT '"This message contains no PGP key."' BT '"_Ok"'
  46.     exit
  47. end
  48.  
  49. if(rc ~= 0) then
  50. do
  51.     REQUESTNOTIFY TEXT '"Search failed. Check path."' BT '"_Ok"'
  52.     exit
  53. end
  54.  
  55. GETGLOBALCONFIG CFG
  56. if(rc ~= 0) then exit
  57.  
  58. address BBSREAD GETGLOBALDATA stem GLOBALDATA
  59. if(rc ~= 0) then exit
  60.  
  61. Call Close 'STDOUT'          
  62. Call Close 'STDIN'
  63. Call Open 'STDOUT','CON:0/13//150/PGPAmiga/SCREEN' || CFG.PUBSCREENNAME
  64. Call Pragma '*','STDOUT'
  65. Call Open 'STDIN','*'
  66.  
  67. if GLOBALDATA.PGPCommand = '' then 
  68. do
  69.     call getpath
  70.     pgpcommand = result
  71. end
  72. else pgpcommand = GLOBALDATA.PGPCOMMAND
  73.  
  74. address command pgpcommand filename ' -ka'   
  75. if(rc ~= 0) then
  76. do
  77.     REQUESTNOTIFY TEXT '"PGP failed. Check Global Config or PGPPATH envirorment variable."' BT '"_Ok"'
  78.     exit
  79. end
  80.  
  81. if exists(filename) then address command 'delete >nil:' filename
  82. exit 0
  83.  
  84.  
  85. getpath: procedure
  86. address command 'GetEnv >PIPE:PGPPATH PGPPATH'
  87. If rc = 0 Then
  88. Do
  89.     If Open('ppath','PIPE:PGPPATH','R') Then
  90.     Do
  91.         path = ReadLN('ppath')
  92.         If ~Close('ppath') Then Nop
  93.         path = path||'/PGP'
  94.         Return path
  95.     End
  96.     Else Return ""
  97. End
  98.